<?php

class Default_FetchController extends Zend_Controller_Action
{
    public function init()
    {
        //$this->_helper->layout()->disableLayout();
        //$this->_helper->viewRenderer->setNoRender();
    }

    public function indexAction()
    {
        $this->_helper->layout()->disableLayout();
        $this->_helper->viewRenderer->setNoRender();

        exit('Error.');
    }

    public function wikiAction()
    {
        if ($this->getRequest()->isPost()) {
            try {
                $this->view->search = $this->_getParam('search');
                $wikipedia = new Zend_Rest_Client('http://en.wikipedia.org/w/api.php');
                $wikipedia->action('query');
                $wikipedia->list('search');
                $wikipedia->srwhat('text');
                $wikipedia->format('xml');
                $wikipedia->srsearch($this->view->search);
                $this->view->result = $wikipedia->get();
            } catch (Exception $e) {
                die('ERROR: ' . $e->getMessage());
            }
        }
    }

    public function googleReaderAction()
    {
        /** @var Application_Model_User */
        $user = Application_Model_User::getResource()->findById(1);
        $accounts = $user->getAccounts();
        $account = $accounts[0];

        $googleReader = new OP_GoogleReader($account->account_id, $account->account_pwd);
        $content  = $googleReader->getAtom();

        var_dump($content);
        exit();
    }

   
}
?>
